<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../taglibs.jsp"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../css/four.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../css/jqe/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../css/jqe/themes/icon.css"/>

    <script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
	
    <script type="text/javascript">

	    function shStu() {
			window.location.href="liststu.do?clzid="+$("#slkt_dps").val();
		}

	    function stustate() {
	    	
	    	var state=$("#stustate").val();
	    	window.location.href="liststu.do?stustate="+$("#stustate").val();
		}
	   
        $(function(){	
        	//是否全选学生添加班级
        	$("#selectAll").click(function(){
        		var isChecked = $(this).prop("checked");
        		$(".stuselect").each(function(i,v){
        			$(v).prop("checked",isChecked);
        		})
        	});
        	//监控添加班级提交按钮
        	$("#addClass").click(function(){
        		var tmp="";
        		var gs=$(".stuselect").length;
        		$(".stuselect").each(function(i,v){
        			if($(v).prop("checked")==true){
    					tmp+=$(v).val()+"_";
    				}
        		})
        		if($("#selectCid").val()>0&&tmp.length>0){
        			window.location.href="updateState.do?stuids="+tmp+"&clzid="+$("#selectCid").val();
        		}else{
        			alert("请选择班级跟选择添加班级的学生")
        		}
        	});
        	
        	
        	//这里监控未分班，会有分班按钮出现
        	var state=$("#stustate").val();
        //	alert(state)
	    	if(state==0){
	    		$("#selectStu").css('display','block' );
	    		$("#fenye").attr('colspan',7);
	    	}else{
	    		$("#selectStu").css('display','none' );
	    		$("#fenye").attr('colspan',8);
	    	}
        	
	    	 //开启添加新学员的页面
      	 	 var ossstu=  $("#checkStu").val();
	    	 
	    	if(ossstu!=null&&ossstu!=''){
	    		$('#dw1').window("open");
	    	}
	    	
        	//初始化对话框
        	 $('#dw,#dwEdit').window({
        		   onBeforeClose:function(){ 
        			   //取消时关闭等待框
        			   setTimeout(function(){ 
        				   sending.style.visibility = "hidden";
					   }, 250);
        	   }});
        	
       
              $(".btnAll").each(function(i,v){
        	   //变手型
        	     $(v).mouseover(function() {
    				$(this).css("cursor", "hand");
    			 }).mouseout(function() {
    				$(this).css("cursor", "pointer");
    			 });
        	   
        	   
        	  
        	   
        	   if($(v).html()=='【学员登记】'){
        		   $(v).click(function(){
        			   $('#dw').window("open");
        		   });
        	   }else if($(v).html()=='【查看该生所有评价】'){
        		   $(v).click(function(){
        			   //ajax
        			   $.get("shAllEval.do?ossstuid="+ $(v).prop("lang")+"&x="+Math.random(),function(jsonTxt){
        				   //这里是查看所有用户 评价
        				   var jsonObj = eval("("+jsonTxt+")");
        				   alert(jsonObj)
        				  
            			$('#shEval').window("open");
        			   });
        		   });
        	   }else if($(v).html()=='【删除】'){
        		   $(v).click(function(){
        			  if(confirm("确认删除'"+$(v).prop("title")+"'?")){
        				  location.href="delCal.do?clzid="+$(v).prop("lang"); 
        			  }
        		   });
        	   } 
        	   else if($(v).html()=='【更改学生信息】'){
        		   $(v).click(function(){
					  location.href="toupdatastu.do?stuid="+$(v).prop("lang"); 		  
        		   });
        	   } 
        	   else if($(v).html()=='【学生考核成绩评价评价】'){
        		   $(v).click(function(){
        				 // location.href="addStuChengji.do?ossstuid="+$(v).prop("lang"); 
        				 $.ajax({
   							type: "POST",
   							url: "selectKhStuname.do",
   							data: "ossstuid="+$(v).prop("lang")+"&time="+new Date().getTime(),
   							success: function(msg){
   							   /* alert(msg)
   							   alert(msg.body.length) */
   							   var temp='';
   							   $("#khossstuid").val($(v).prop("lang"));
								$("#khstuname").val(msg.body[0].stuname); //添加名字
   							   if(msg.head='ok'){
   								  $(msg.body).each(function(i,v){
   									temp+="<option name='themeid' value="+v.themeid+">"+v.thename+"</option>";
   								  })
   								  $("#kaohezhuti").append(temp);
   							   }else if(msg.head=='err'){
   									temp+="<option>没有考核主题</option>";
   									$("#kaohezhuti").append(temp);
    				    		}	
   							}
						});
        				 
        				  $("#addStukh").window("open");
        		   });
        	   } 
        	   else if($(v).html()=='【学生评价】'){
        		   $(v).click(function(){
        			   //开启添加评价
        			   $.ajax({
   							type: "POST",
   							url: "shPjstu.do",
   							data: "ossstuid="+$(v).prop("lang")+"&time="+new Date().getTime(),
   							success: function(msg){
   							//	alert(msg.body.ename)
   							   if(msg.head=='ok'){
   								   $("#pjstuname").val(msg.body.stuname);
   								   $("#pjename").val(msg.body.ename);
   									$("#pjeid").val(msg.body.eid);
   									$("#pjossstuid").val(msg.body.ossstuid);
   								}
   							}
						});
        			   $('#pj').window("open");
        		   });
        	   } 
           });
        });
    </script>
</head>
<body>

	<!-- 包含等待框 -->
	<jsp:include page="../waittable.jsp" flush="true" />
	<input type="hidden"  id="checkStu" value="${ossstu }" />
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr valign="top">
			<td bgcolor="#FFFFFF"><table width="96%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
					<tr align="left" bgcolor="#F2FDFF">
						<td colspan="4" class="optiontitle">
						 <select name="slkt_dps" id="slkt_dps" onchange="shStu()">
						    <option  value="0" >全部</option>
						    <c:forEach items="${classes}" var="cla">
						       <option   ${page.params.clzid==cla.clzid?"selected='selected'":""} value="${cla.clzid}">${cla.clzname}</option>
						    </c:forEach>
						 </select>
						  学生列表</td>
						  <td colspan="4" class="optiontitle">
						 <select name="stustate" id="stustate" onchange="stustate()"  } >
						    	<option   ${page.params.stustate==null?"selected='selected'":""}>全部</option>
						        <option  value="0" ${page.params.stustate==0?"selected='selected'":""}>未分班</option>
						    	<option   value="1" ${page.params.stustate==1?"selected='selected'":""}>已分班</option>
						    	<option   value="2" ${page.params.stustate==2?"selected='selected'":""}>休学</option>
						    	<option  value="3" ${page.params.stustate==3?"selected='selected'":""}>毕业</option>    
						 </select>
						  学生状态</td>
					</tr>
					
					<tr align="center">
						<td align="center" bgcolor="#ebf0f7">学生编号</td>
						<td align="center" bgcolor="#ebf0f7">学生姓名</td>
						<td align="center" bgcolor="#ebf0f7">性别</td>
						<td align="center" bgcolor="#ebf0f7">电话</td>
						<td align="center" bgcolor="#ebf0f7">年龄</td>
						<td align="center" bgcolor="#ebf0f7">入学时间</td>
						<td align="center" bgcolor="#ebf0f7">学习状态</td>
						<td align="center" bgcolor="#ebf0f7">操作 <span class="btnAll">【学员登记】</span> </td>
					</tr>
					<c:forEach items="${page.results}" var="dpt">
						<tr align="center" bgcolor="#FFFFFF">
						    <td align="center" bgcolor="#ebf0f7"><input class="stuselect"  type="checkbox" value="${dpt.ossstuid}"/>${dpt.ossstuid}</td>
							<td align="center">${dpt.stuname}</td>
							<td align="center">${dpt.stusex==1?'男':'女'}</td>
							<td align="center">${dpt.stucellphone}</td>
							<td align="center">${dpt.ossstuage}</td>
							<td align="center"><fmt:formatDate value="${dpt.joinDate}" pattern="yyyy-MM-dd"/></td>
							<td align="center">
								<c:if test="${dpt.stustate==0 }" >未分班</c:if>
								<c:if test="${dpt.stustate==1 }" >已分班</c:if>
								<c:if test="${dpt.stustate==2 }" >毕业</c:if>
								<c:if test="${dpt.stustate==3 }" >休学</c:if>
							</td>
							<td align="center">
						【<a href="#"></a>】<c:if test="${lgnUsr.eid > 0}">
									| <span class="btnAll" lang="${dpt.ossstuid }">【更改学生信息】</span>
									| <span class="btnAll" lang="${dpt.ossstuid }">【学生考核成绩评价评价】</span>
									| <span class="btnAll" lang="${dpt.ossstuid }">【学生评价】</span>
								    | <span class="btnAll" lang="${dpt.ossstuid }" title="">【查看该生所有评价】</span>
								    | <span class="btnAll" lang="${dpt.clzid }" title="">【删除】</span>
				                   </c:if>
							</td>
						</tr>
					</c:forEach>
					<tr align="right" bgcolor="#ebf0f7">
							<td colspan="4" align="left" id="selectStu" style="display: none"><input id="selectAll" type="checkbox" />全选
								<select name="slkt_dps" id="selectCid"">
						  			  <option  value="0" selected="selected">选择班级</option>
						    		  <c:forEach items="${classes}" var="cla">
						      			 <option  name="stateCid" ${page.params.clzid==cla.clzid?"selected='selected'":""} value="${cla.clzid}">${cla.clzname}</option>
						   		      </c:forEach>
						 		</select>
						 		<button id="addClass">提交</button>
							</td>
								<td colspan="8" id="fenye">
								<jk:page totalPage="${page.totalPage}" pageNo="${page.pageNo}" totalRecord="${page.totalRecord}"
	                                url="liststu.do"/>
								</td>	
					</tr>
				</table>
			</td>
		</tr>
		<tr>
		  <td align="center" style="color: red">${msg}</td>
		</tr>
	</table>
  
	<div id="dw1" class="easyui-window" title="添加新学员" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		<form action="addstu.do" method="post">
		     学生姓名：<input name="stuname" value= ${ossstu.stuname }   /> <br><br> 
		     学生电话:<input name="stucellphone" value=${ossstu.stucellphone }  /><br><br>
		   学生年龄:<input name="ossstuage" value=${ossstu.ossstuage }  /><br><br>
		     性别：<input name="sex" value=${empty ossstu? ossstu.stusex==1?"男":"女" :"" }/><br><br> 
			入学时间:<input name="joinDate" value="${ossstu.joinDate }" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/><br><br> 
			
		   <input type="submit" value="登记学生"/><br>
		</form> 
		<c:if test=""></c:if>
	</div>
	
	
	
	<div id="dw" class="easyui-window" title="查询新学员有没有咨询过" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		<form action="ToaddStu.do" method="post">
		     学生姓名：<input name="stuname" /><br><br> 
		     学生电话:<input name="stuphone"/><br><br>
		   <input type="submit" value="查询"/><br>
		</form>
	</div>
	
	<div id="pj" class="easyui-window" title="添加学生评价" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		<form action="addEvaluete.do" method="post">
		<input type="hidden" id="pjeid" name="eid" value=""/>
		<input type="hidden" id="pjossstuid" name="ossstuid" value=""/>
		     学生姓名：<input name="stuname" id="pjstuname" /><br><br> 
		   学生班主任:<input name="ename"  id="pjename"/><br><br> 
		    评价时间:<input name="evdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" /><br><br>
		    评价内容:<textarea name="evcontent" rows="3" cols="30" id="pj_note"></textarea><br><br>
		   <input type="submit" value="添加评价"/><br>
		</form>
	</div>
	
	<div id="shEval" class="easyui-window" title="查看该学生所有评价" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:500px;height:200px;padding:10px;display: none;">
		<c:forEach  items="${EvaList }" var="eva">
			<label> <fmt:formatDate value="${eva.evdate }" pattern="yyyy-MM-dd" /> </label>
			<input type="text" value="${eva.evcontent }" /><br></br>
		</c:forEach>
	</div>
	
	 <div id="dwEdit" class="easyui-window" title="修改部门信息" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		<form action="<%=basePath%>stu/updD.do" method="post">
		<input name="depID" id="upd_depID" type="hidden"   />
		     部门名称：<input name="depname" id="upd_depname"   /><br><br>
		     备注 ：<textarea name="dnote" rows="3" cols="30" id="upd_dnote"></textarea><br><br>
		      <input type="submit" value="修改"/><br>
		</form>
	</div>
	
	<div id="addStukh" class="easyui-window" title="添加学生考核成绩评价" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		<form action="<%=basePath%>stu/addStuChengji.do" method="post">
		<input name="ossstuid" id="khossstuid" type="hidden"   />
		     学生名称：<input  id="khstuname"  readonly="readonly" /><br><br>
		     选择考核科目: 
		     <select id="kaohezhuti" name="themeid">
		     	
		     </select>
		     <br><br>
		     成绩：<input name="score" id="upd_depname"   /><br><br>
		     考试评价 ：<textarea name="scoredescb" rows="3" cols="30" id="upd_dnote"></textarea><br><br>
		      <input type="submit" value="修改"/><br>
		      
		</form>
	</div>
	
</body>
</html>